package com.leon.plugin;


import com.leon.datalink.plugin.DataLinkPlugin;
import com.leon.datalink.plugin.OutputChannel;

import java.util.Map;

/**
 * 自定义节点
 */
public class DemoPlugin implements DataLinkPlugin {

    /**
     * 节点启动
     *
     * @param configJson    配置
     * @param context       上下文
     * @param outputChannel 输出通道
     * @throws Exception 异常
     */
    @Override
    public void onStart(String configJson, Map<String, Object> context, OutputChannel outputChannel) throws Exception {
        System.out.println("onStart configJson: " + configJson);
        System.out.println("onStart context: " + context);

        // todo something

    }

    /**
     * 节点停止
     *
     * @throws Exception 异常
     */
    @Override
    public void onStop() throws Exception {
        System.out.println("onStop");

        // todo something

    }

    /**
     * 输入数据
     *
     * @param context       上下文
     * @param variable      变量
     * @param data          上游数据
     * @param outputChannel 输出通道
     * @throws Exception 异常
     */
    @Override
    public void onInput(Map<String, Object> context, Map<String, Object> variable, Object data, OutputChannel outputChannel) throws Exception {
        System.out.println("onInput data: " + data);
        System.out.println("onInput variable: " + variable);
        System.out.println("onInput context: " + context);

        // todo something

    }

}
